package org.scboy.common;

import org.scboy.common.filter.HttpBodyRecorderFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

	@Bean
	public HttpBodyRecorderFilter getHttpBodyRecorderFilter() {
		return new HttpBodyRecorderFilter();
	}
	
	@Bean
	public FilterRegistrationBean<HttpBodyRecorderFilter> getFilterRegistrationBean(){
		FilterRegistrationBean<HttpBodyRecorderFilter> filterRegistrationBean=new FilterRegistrationBean<HttpBodyRecorderFilter>();
		filterRegistrationBean.setFilter(getHttpBodyRecorderFilter());//设置过滤器名称
		filterRegistrationBean.addUrlPatterns("/*");//配置过滤规则
		filterRegistrationBean.setOrder(1); //order的数值越小 则优先级越高
		return filterRegistrationBean;
	}
}
